package br.com.model.dao;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class ConnectionManager 
{
	private static EntityManagerFactory factory;
	
	private ConnectionManager( )
	{
		
	}
	
	public static EntityManager getEntityManager( )
	{
		if( factory == null )
		{
			factory = Persistence.createEntityManagerFactory( "tarefas" );
		}
		
		return factory.createEntityManager( );
	}
	
	public static void closeEntityManager( EntityManager entity )
	{
		entity.close( );
	}
}